package uit.nfcmenu.utils;

import java.net.URLEncoder;

import android.util.Log;



public class CommUrl {
	public static final String tag = CommUrl.class.getSimpleName();
	
	
	
	// ===========================================
	// Visual Menu APIs for Web Service
	// ===========================================
	
	/**
	 * create URL for Getting all foods and drinks 
	 */	
	public static String createUrlGetAllFoodsAndDrinks() {
		// TODO need api for this
		return "http://r-service.appspot.com/resources/menu";
	}
	
	/**
	 * create URL for Posting orders
	 */	
	public static String createUrlPostOrderItem() {
		// TODO need api for this
		return "";
	}
	
//	/**
//	 * create URL for Get all statuses of items for Chief
//	 */	
//	public static String createUrlGetItemsStatus() {
//		// TODO need api for this
//		return "";
//	}
	
	/**
	 * create URL to Get all statuses of items for Waiter
	 */	
	public static String createUrlGetChangeFoodAndDrinks() {
		// TODO need api for this
		return "";
	}

	/**
	 * create URL to get menu
	 * @return
	 * Ex: http://r-service.appspot.com/resources/menu
	 */
	private static final String webURL="http://r-service.appspot.com/resources/";
	public static String createUrlGetMainMenuInServer() { 
		// TODO Auto-generated method stub
		return webURL+"menu/mainmenu";
	}
	
	public static String createUrlGetSubMenuInServer() { 
		// TODO Auto-generated method stub
		return webURL+"menu/submenu";
	}

	public static String createUrlGetOrderInServer() {
		// TODO Auto-generated method stub
		return webURL+"order";
	}
	
	/**
	 * create URL for Get all statuses of items for Waiter
	 */	
	public static String createUrlGetItemsStatus() {
		// TODO need api for this
		return webURL+"item";
	}
	
	
	/**
	 * Post Order
	 */
	
	public static String createUrlPostOrder(int itemid, String status, int tableNo, int quantity, String comment) {
		String url = webURL+"order/"+itemid+","
				+status+","+tableNo+","+quantity+","+URLEncoder.encode(comment+" ").replace("+", "%20");
		return url;
	}
	
	/**
	 * Change status of order
	 */
	public static String createUrlChangeOrderStatus(int orderId, String newStatus,String comment) {
		if(comment==null){
		comment=" ";
		}
		return webURL+"order/"+orderId+"/status/"+newStatus+","+URLEncoder.encode(comment).replace("+", "%20");
	}
	
	/**
	 * Delete item
	 */
	
	public static String createUrlDeleteItem(int itemId) {
		return webURL+"item/delete/"+itemId;
	}
	
	/**
	 * Insert Item without image
	 */
	public static String createUrlInsertItemWithoutImage(String itemname, 
			int price, int menuid, String description, int discount) {
		return webURL+"item/"
			+itemname+","+price+","+menuid+","+description+","+discount;
	}
	
	/**
	 * Edit item with given id
	 */
	public static String createUrlEditItem(int itemid, String itemname, 
			int price, String description, int discount) {
		return webURL+"item/"
			+itemid+","+itemname+","+price+","+description+","+discount;
	}
}

